/**
 * 
 */
package com.xbang.attendance.web.action.warehouse.exchange;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.xbang.attendance.entity.stock.Inventory;
import com.xbang.attendance.entity.stock.InventoryExchange;
import com.xbang.attendance.service.InventoryService;
import com.xbang.attendance.service.SystemService;
import com.demo2do.lighturl.annotation.Action;
import com.xbang.core.dao.search.component.SearchComponent;
import com.xbang.core.page.Result;
import com.xbang.core.struts.support.SearchActionSupport;
import com.xbang.core.utils.DateUtils;

import enumeration.InventoryOperation;

/**
 * @author dev.zhang
 */
public class Index extends SearchActionSupport {

	private static final long serialVersionUID = 2886204759816132683L;

	@Autowired
	private SystemService systemService;

	@Autowired
	private InventoryService inventoryService;

	private List<InventoryExchange> inventoryExchanges = new ArrayList<InventoryExchange>();

	private Inventory inventory;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {

		inventoryExchanges = inventoryService.getObjects(InventoryExchange.class);

		return super.execute();
	}


	@Action("/warehouse/exchange/list")
	public String list() throws Exception {

		String hqlSentence = "FROM InventoryExchange inventoryExchange WHERE 1 = 1 ";

		Result result = inventoryService.searchByPage(hqlSentence, searchComponent, page);
		inventoryExchanges = result.getItems();
		page = result.getPage();

		return "index";
	}

	

	/**
	 * @return the inventoryExchanges
	 */
	public List<InventoryExchange> getInventoryExchanges() {
		return inventoryExchanges;
	}

	/**
	 * @param inventoryExchanges
	 *            the inventoryExchanges to set
	 */
	public void setInventoryExchanges(List<InventoryExchange> inventoryExchanges) {
		this.inventoryExchanges = inventoryExchanges;
	}

	/**
	 * @param systemService
	 *            the systemService to set
	 */
	public void setSystemService(SystemService systemService) {
		this.systemService = systemService;
	}

	/**
	 * @param inventoryService
	 *            the inventoryService to set
	 */
	public void setInventoryService(InventoryService inventoryService) {
		this.inventoryService = inventoryService;
	}

	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub

	}

	public SystemService getSystemService() {
		return systemService;
	}

	public InventoryService getInventoryService() {
		return inventoryService;
	}


}
